﻿<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="JavaScriptPostBack.aspx.vb" Inherits="WebPhonebook.JavaScriptPostBack" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<script language="JavaScript">
    //ask for user input and then create file
    function CreateFile() {
        //get filename from the user
        var fileName = prompt('Type the name of the file you want to create:', '');
        //if the user clicks on OK and if they have entered something
        if ((fileName) && (fileName != "")) {
            //save the filename to the hidden form field 'funcParam'
            document.forms['myForm'].elements['funcParam'].value = fileName;
            //call the postback function with the LinkButton's ID, so the server thinks the LinkButton submitted the form
            __doPostBack('CreateFile', '');
        }
    }
</script>
</head>
 
<body>
<form runat="server" id="myForm">
 <a href="javascript:CreateFile();">Create Text file</a>
 <asp:linkbutton id="CreateFile" runat="server" onclick="CreateFile_Click" />
 <input type="hidden" runat="server" id="funcParam">
</form>
</body>
</html>
